fix(ng-dev): validate nvmrc-sourced Node.js version before fetch#3738
Merged
josephperrott merged 2 commits intoJun 8, 2026
Merged
Conversation
#75773923 added `semver.valid()` guards to the PNPM and TypeScript version strings before they are interpolated into registry fetch URLs, but the Node.js version was left unguarded. In `processNodeToolchainArgs`, `effectiveVersion` can originate from the `.nvmrc` file and flows into `getNodeJsRepositories`, which interpolates it into `fetch(`https://nodejs.org/dist/v${version}/SHASUMS256.txt`)` without validation. Apply the same `semver.valid()` check to `effectiveVersion` before it is used, matching the guards already added for PNPM and TypeScript.
There was a problem hiding this comment.
Code Review
This pull request introduces validation for the Node.js version using semver.valid in sync-module-bazel.ts to ensure only valid versions are processed. The reviewer identified an issue where using the original effectiveVersion instead of the normalized version returned by semver.valid could result in a double 'v' prefix (e.g., 'vv24.16.0') in URLs, and provided a code suggestion to fix this.
0c20293 to
34d6c76
Compare
Member
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#75773923 added
semver.valid()validation to the PNPM and TypeScript version strings before they are interpolated into registry fetch URLs (syncPnpm,syncTypeScript), but the Node.js version path was left unguarded.In
processNodeToolchainArgs(ng-dev/misc/sync-module-bazel/sync-module-bazel.ts),effectiveVersioncan originate from the.nvmrcfile (node_version_from_nvmrc) and is passed togetNodeJsRepositories, which interpolates it into:without the same validation, leaving the URL path open to manipulation via the version string.
Fix
Apply the existing
semver.valid()guard toeffectiveVersionbefore it is used, consistent with the PNPM and TypeScript checks added in #75773923.